/* Start Header
*****************************************************************/
/*!
\file   CommonMessages.h
\author <Liu Wei Long, weilong.liu, 250002510>
        <Liu Zhi Yang, zhiyang.liu, 300000111>
\par    <email: weilong.liu\@digipen.edu> 
        <email: zhiyang.liu\@digipen.edu> 
\date   <Apr 3, 2012>
\brief
Copyright (C) 2012 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the
prior written consent of DigiPen Institute of Technology is prohibited.
*/
/* End Header
*******************************************************************/
#ifndef _COMMONMESSAGES_H_
#define _COMMONMESSAGES_H_

#include <string>
#include "WinsockHeaders.h"

#define UDP_RECV_BUFFER_SIZE 1430
#define DATA_SIZE 51150 
#define IDLE_TIMER 5000
#define INVALID_PACKET -1

// A list of valid input messages
namespace MessageType
{
	const std::string Username("username//");
	const std::string SharedFiles("shared//");
	const std::string AddDownloadList("decline");
	const std::string Exit("Exit");
	const std::string TerminateDownload("/Terminate/");
	const std::string TerminateACK("/TerminateACK/");
};

enum TaskType
{
	CONNECT,
	DISCONNECT,
	MOVE,
	GAMETASK,
	FIRE,
	INVALID,
};

struct ClientTask
{
	unsigned type;
	unsigned id;
	unsigned seqNum;
	char buffer[UDP_RECV_BUFFER_SIZE];

	ClientTask() : type(INVALID), id(0), seqNum(0) 
		{}
};

struct GameTask
{
	unsigned int type;
	unsigned int id;
	unsigned int seqNum;
	int direction;

	GameTask() : type(INVALID), id(0), seqNum(0), direction(0) 
		{}
};

struct ServerGameStatus
{
	int type;
	unsigned int seqNum;
	float playerX[4];
	float playerY[4];
	float playerFacing[4];
	float BulletX[4][5];
	float BulletY[4][5];
	float asteroidsX[50];
	float asteroidsY[50];
	char asteroidActive[50];
	int score[4];
	bool IsBullet[4][5];
	char username[4][5];
	bool playerActive[4];
	bool gameEnd;
	int winner;

	ServerGameStatus(void) : type(INVALID), seqNum(0), gameEnd(false), winner(0)
	{
		std::memset(asteroidActive, 0, sizeof(asteroidActive));
		std::memset(IsBullet, 0, sizeof(IsBullet));
		std::memset(playerActive, 0, sizeof(playerActive));
	}
};

struct ACKPacket
{
  unsigned int mAckedNumber;
  operator const char*()
  {
    return (const char*)&mAckedNumber;
  }
};

#endif

